﻿using System;
using System.Windows;
using System.Windows.Input;

namespace MDCAdminTool.Commands
{
    public class RemoveCacheName : AsyncCommandBindingBase
    {
        public RemoveCacheName()
        {
            Command = Application.Current.Resources["RemoveCacheName"] as ICommand;
        }

        protected override void OnExecuted( object sender , ExecutedRoutedEventArgs e )
        {
            var cache = e.Parameter as MdcCache;

        	if (ShowConfirmationBox("Do you really want to remove the cache?") != MessageBoxResult.Yes) 
				return;
        	
			if (cache != null)
        	{
        		cache.Parent.Remove(cache);
        	}
        }

    	protected override void OnCanExecute( object sender , CanExecuteRoutedEventArgs e )
        {
            e.CanExecute = true;
        }
    }
}